//引入saga辅助函数
import { takeEvery, call, put } from "redux-saga/effects"
import { GET_MYROOM_LIST } from "../actionType"
import api from "../../api/index"
export function* myRoom() {

    //辅助函数takeEvery在每次dispatch时监听执行
    yield takeEvery("GETROOMLIST", function* () {
        //call方法第一个参数一个函数返回的是promise，剩余参数是此函数的参数
        const res = yield call(api.getMyRoomList);
        //put函数相当于dispatch 提交action一样
        yield put({
            type: GET_MYROOM_LIST,
            payload: [...res.body]
        })
    })
}